import axios from 'axios'
import * as actionTypes from './actionTypes'


const changeLoginStatus = (status) => ({ //更改登录状态
  type: actionTypes.LOGIN_USER,
  status
})

export const changeLogOut = () => ({
  type: actionTypes.CHANGE_LOGOUT
})

// 向后台发送数据，请求登录接口
export const loginCheck = (account, password) => {
  return async (dispatch) => {
    const { data: res } = await axios.get('/api/login.json?account=' + account + '&password=' + password);
    dispatch(changeLoginStatus(res.data));
  }
}